import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CakeMaterialVO, CakeMaterialForm, CakeMaterialQuery } from '@/api/sj/cakeMaterial/types';

/**
 * 查询蛋糕基础材质列表
 * @param query
 * @returns {*}
 */

export const listCakeMaterial = (query?: CakeMaterialQuery): AxiosPromise<CakeMaterialVO[]> => {
  return request({
    url: '/sj/cakeMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询蛋糕基础材质详细
 * @param id
 */
export const getCakeMaterial = (id: string | number): AxiosPromise<CakeMaterialVO> => {
  return request({
    url: '/sj/cakeMaterial/' + id,
    method: 'get'
  });
};

/**
 * 新增蛋糕基础材质
 * @param data
 */
export const addCakeMaterial = (data: CakeMaterialForm) => {
  return request({
    url: '/sj/cakeMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改蛋糕基础材质
 * @param data
 */
export const updateCakeMaterial = (data: CakeMaterialForm) => {
  return request({
    url: '/sj/cakeMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除蛋糕基础材质
 * @param id
 */
export const delCakeMaterial = (id: string | number | Array<string | number>) => {
  return request({
    url: '/sj/cakeMaterial/' + id,
    method: 'delete'
  });
};
